<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Waner - 个人信息</title>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" type="text/css" th:href="@{/layuiadmin/layui/css/layui.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/layuiadmin/myfile/main.css}">
</head>
<body class="micronews">
<div class="micronews-header-wrap">
    <div class="micronews-header w1000 layui-clear">
        <h1 class="logo">
            <a href="/">
                <img width="66px" height="22px" th:src="@{/layuiadmin/myfile/images/logo3.png}" alt="logo">
                <span class="layui-hide">logo</span>
            </a>
        </h1>
        <p class="nav">
            <a href="/front/page/index">推荐</a>
            <a href="/travel-essay/list-page">游记</a>
            <a href="/question/list-page">问答</a>
        </p>
        <div class="search-bar">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="text" name="title" placeholder="搜索你要的内容" autocomplete="off" class="layui-input">
                        <button class="layui-btn search-btn" formnovalidate><i class="layui-icon layui-icon-search"></i>
                        </button>
                    </div>
                </div>
            </form>
        </div>
        <div class="login">
            <a th:if="${session.sessionUser == null}" href="/front/page/login">
                登录
            </a>
            <!--<img th:src="@{/layuiadmin/myfile/images/header.png}" style="width: 36px; height: 36px;">-->
            <ul th:if="${session.sessionUser != null}" class="layui-nav" style="background-color: #fff;"
                lay-filter="component-nav">
                <li class="layui-nav-item">
                    <a href="/travel-essay/page" style="font-size: 16px;color: #222;">写游记</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/question/form-page" style="font-size: 16px;color: #222;">提问</a>
                </li>
                <li class="layui-nav-item" lay-unselect="">
                    <a href="javascript:;" style="font-size: 16px;color: #222;"><span
                            th:text="${session.sessionUser.nickname}"></span></a>
                    <dl class="layui-nav-child">
                        <dd style="text-align: center;"><a href="/user/info-form">修改信息</a></dd>
                        <dd style="text-align: center;"><a href="/user/person-info">个人资料</a></dd>
                        <dd layadmin-event="logout" style="text-align: center;"><a href="javascript:;">退出登录</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
        <div class="menu-icon">
            <i class="layui-icon layui-icon-more-vertical"></i>
        </div>
    </div>
</div>

<div class="micronews-container micronews-search-container w1000">
    <div class="layui-fluid" >
        <div id="view">

        </div>
        <div id="page" style="text-align: center; padding:30px 0"></div>
    </div>
</div>

<!-- content-laytpl -->
<script id="laytpl" type="text/html">
    <p class="num">为您找到相关结果为<span> &nbsp;{{d.count}}&nbsp; </span>个</p>
    <div class="item-list">
        {{#  layui.each(d.data, function(index, item){ }}
        <div class="item">
            <h4>
                <span style="background-color: #6294b5;color: white;border-style: ridge ;">{{item.tag}}</span>
                {{# if(item.tag === '推荐'){ }}
                <a href="/recommend/detail-page?id={{item.id}}">{{item.title}} </a>
                {{# } }}
                {{# if(item.tag === '游记'){ }}
                <a href="/travel-essay/detail-page?id={{item.id}}">{{item.title}} </a>
                {{# } }}
                {{# if(item.tag === '问答'){ }}
                <a href="/question/detail-page?id={{item.id}}">{{item.title}} </a>
                {{# } }}
                <span class="time">{{item.createTime}}</span>
            </h4>
<!--            <p ><xmp>{{item.content}}</xmp></p>-->
        </div>
        {{#  }); }}
    </div>
</script>
<!-- end-content-laytpl-->


<div class="micronews-footer-wrap">
    <div class="micronews-footer w1000">
        <div class="Copyright">
            <span>Copyright&nbsp;</span>&nbsp;&copy;<span>Waner旅游网&nbsp;&nbsp;</span>
        </div>
    </div>
</div>

<script th:src="@{/layuiadmin/layui/layui.js}"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'news', 'laytpl', 'laypage'], function () {
        var news = layui.news
            , laytpl = layui.laytpl
            , laypage = layui.laypage
            , admin = layui.admin;

        var page = 1;
        var limit = 10;
        var urlInfo = window.location.href;
        var info = urlInfo.split("?")[1].split("=")[1];
        var pattern = decodeURI(info);
        // var pattern = GetQueryString('pattern');
        // 加载数据
        loadData();


        function loadData() {
            admin.req({
                url: '/common/search-list'
                , type: 'get'
                , async: false
                , data: {
                    limit: limit,
                    page: page,
                    pattern: pattern
                }, success: function (res) {
                    // 获取节点
                    var getTpl = document.getElementById('laytpl').innerHTML;
                    // 执行tpl渲染
                    laytpl(getTpl).render(res, function (html) {
                        document.getElementById('view').innerHTML = html;
                    });
                    // 执行分页
                    laypage.render({
                        elem: 'page'
                        , count: res.count
                        , first: '首页'
                        , last: '尾页'
                        , prev: '<em>←</em>'
                        , next: '<em>→</em>'
                        , limit: limit
                        , jump: function (obj, first) {
                            page = obj.curr;
                            limit = obj.limit;
                            if (!first) {
                                // loadData();
                                admin.req({
                                    url: '/common/search-list'
                                    , type: 'get'
                                    , async: false
                                    , data: {
                                        limit: limit,
                                        page: page,
                                        pattern: pattern
                                    }, success: function (res) {
                                        // 获取节点
                                        var getTpl = document.getElementById('laytpl').innerHTML;
                                        // 执行tpl渲染
                                        laytpl(getTpl).render(res, function (html) {
                                            document.getElementById('view').innerHTML = html;
                                        });
                                    }
                                });
                            }
                        }
                    });
                }
            });
        }



        // news.omitted('.item-list .item p xmp', 150);
        news.seachBtn();
        news.arrowutil();
    });
</script>
</body>
</html>